﻿using System;


namespace task2
{
    class arrey
    {
        static void Main(string[] arg)
        {
            int[] array = { 1, 2, 3, 4, 5, 6, 7, 8 };
            /*从控制台输入数组
            int length = Convert.ToInt32(Console.ReadLine());
            int[] arry = new int[length];
            for (int i = 0; i < length; i++)
            {
                arry[i] = Convert.ToInt32(Console.ReadLine());
            }*/

            Min(array);
            Max(array);
            Average(array);



        }

        public static void Min(int[] array)
        {
            int min = array[0];
            for(int i = 1;i <= array.Length - 1; i++)
            {
                if (array[i] < min)
                {
                    min = array[i];
                }
            }
            Console.WriteLine("最小值为{0}",min);
        }

        public static void Max(int[] array)
        {
            int max = array[0];
            for (int i = 1; i <= array.Length - 1; i++)
            {
                if (array[i] > max)
                {
                    max = array[i];
                }
            }
            Console.WriteLine("最小值为{0}", max);
        }

        public static void Average(int[] array)
        {
            int sum = 0;
            int aver;
            for (int i =0; i < array.Length ;i++)
            {
                sum = sum + array[i];
            }

            Console.WriteLine("总和为{0}", sum);
            aver = sum / array.Length;
            Console.WriteLine("平均值为{0}", aver);

        }
    }
}
